import requests
import unittest
class TestIhrmLogin(unittest.TestCase):
    def test01_login_success(self):
        session=requests.Session()
        resp=session.post(
            url="http://ihrm-test.itheima.net/api/sys/login",
            json={"mobile": "13800000002", "password": "123456"}
        )
        self.assertEqual(200,resp.status_code)
        self.assertEqual(True, resp.json().get("success"))
        self.assertEqual(10000, resp.json().get("code"))
        self.assertEqual("操作成功！", resp.json().get("message"))
    def test02_pwd_err(self):
        session=requests.Session()
        resp=session.post(
            url="http://ihrm-test.itheima.net/api/sys/login",
            json={"mobile": "13800000002", "password": "12345600"}
        )
        self.assertEqual(200, resp.status_code)
        self.assertEqual(False, resp.json().get("success"))
        self.assertEqual(20001, resp.json().get("code"))
        self.assertEqual("用户名或密码错误", resp.json().get("message"))

    def test03_tel_not_found(self):
        session = requests.Session()
        resp = session.post(
            url="http://ihrm-test.itheima.net/api/sys/login",
            json={"mobile": "13810000002", "password": "123456"}
        )
        self.assertEqual(200, resp.status_code)
        self.assertEqual(False, resp.json().get("success"))
        self.assertEqual(20001, resp.json().get("code"))
        self.assertEqual("用户名或密码错误", resp.json().get("message"))
